<!DOCTYPE html>
<body>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<div id="log"></div>
<input value="foo" style="border:0; padding:0;" placeholder="input">
<textarea style="border:0; padding:0;" placeholder="textarea">foo</textarea>
<script>
test(function() {
    var input = document.querySelector('input');
    input.focus();
    input.selectionStart = 0;
    input.selectionEnd = 0;
    eventSender.mouseMoveTo(input.offsetLeft + input.offsetWidth - 10, input.offsetTop + 4);
    eventSender.mouseDown();
    eventSender.mouseUp();
    eventSender.mouseDown();
    eventSender.mouseUp();
    assert_equals(input.selectionStart, 0);
    assert_equals(input.selectionEnd, 3);
}, 'Double-clicking whitespace after the value in an INPUT element should select the last word.');

test(function() {
    var textarea = document.querySelector('textarea');
    textarea.focus();
    textarea.selectionStart = 0;
    textarea.selectionEnd = 0;
    eventSender.mouseMoveTo(textarea.offsetLeft + textarea.offsetWidth - 10, textarea.offsetTop + 4);
    eventSender.mouseDown();
    eventSender.mouseUp();
    eventSender.mouseDown();
    eventSender.mouseUp();
    assert_equals(textarea.selectionStart, 0);
    assert_equals(textarea.selectionEnd, 3);
}, 'Double-clicking whitespace after the value in a TEXTAREA element should select the last word.');
</script>
</body>
